<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<ui:composition template="/template/system.xhtml">
	<ui:define name="content">
		<h:outputText value="Bem vindo #{usuarioSessionController.usuario.username}..." />
		<h:form prependId="false">
			<p:commandButton actionListener="#{perfilController.prepareAddModel}"
				value="Novo Perfil" update="perfilForm" oncomplete="dialogGerPerfil.show()" />
			<p:dataTable id="tabela" var="perfil" value="#{perfilController.listDataModel}">
				<p:column>
					<f:facet name="header">
						<h:outputText value="Perfil" />
					</f:facet>
					<h:outputText value="#{perfil.authority}" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Alterar" />
					</f:facet>
					<p:commandButton
						actionListener="#{perfilController.prepareEditModel}"
						value="Alterar" update="perfilForm"
						oncomplete="dialogGerPerfil.show()" />
				</p:column>
				<p:column>
					<f:facet name="header">
						<h:outputText value="Excluir" />
					</f:facet>
					<h:commandLink action="#{perfilController.deleteModel}"
						value="Excluir" />
				</p:column>
			</p:dataTable>
		</h:form>
		<p:dialog header="Gerenciamento de perfil" widgetVar="dialogGerPerfil"
			resizable="false" modal="true" showEffect="slide" width="500">
			<h:form prependId="false">
				<h:panelGrid id="perfilForm" columns="2" style="margin-bottom:10px">
					<h:outputLabel for="perfil" value="Perfil" />
					<h:inputText id="perfil" value="#{perfilController.model.authority}" />
					<p:commandButton update="tabela,messages" oncomplete="dialogGerPerfil.hide();"
						actionListener="#{perfilController.saveModel}" value="Salvar" />
				</h:panelGrid>
			</h:form>
		</p:dialog>
	</ui:define>
</ui:composition>
</html>